PLASTIC AI


G17 University Ambassadors Consortium
SDG Goal 14 - Life below water
University of Moratuwa
P M Ranasinghe

TheGlobalGoals_Icons_Color_Goal_14.png

Training of YOLOv4-model

3.jpg

STEPS TO FOLLOW

Download pre-trained YOLOv4 weights

Define Helper Functions

Uploading Local or Google Drive Files to Use

Configuring Files for Training

This step involves properly configuring your custom .cfg, obj.data, obj.names, train.txt and test.txt files.

i) Cfg File

ii) obj.names and obj.data

obj.data

classes = 1
train  = data/train.txt
valid  = data/test.txt
names = data/obj.names
backup = /mydrive/yolov3-tiny/training

obj.names

Plastic

Generating train.txt and test.txt

Now simply run both scripts to do the work for you of generating the two txt files.

If you are uncertain whether generating the files worked and want to double check that everything went as planned, double click on train.txt on the left side File Explorer and it should look like this.

image.png

It will contain one line for each training image path.

Step 4: Download pre-trained weights for the convolutional layers.

This step downloads the weights for the convolutional layers of the YOLOv4 network. By using these weights it helps your custom object detector to be way more accurate and not have to train as long. You don't have to use these weights but trust me it will help your modle converge and be accurate way faster. USE IT!

Training!

TIP: This training could take several hours depending on how many iterations you chose in the .cfg file. You will want to let this run as you sleep or go to work for the day, etc. However, Colab Cloud Service kicks you off it's VMs if you are idle for too long (30-90 mins).

To avoid this hold (CTRL + SHIFT + i) at the same time to open up the inspector view on your browser.

Paste the following code into your console window and hit Enter

function ClickConnect(){
console.log("Working"); 
document
  .querySelector('#top-toolbar > colab-connect-button')
  .shadowRoot.querySelector('#connect')
  .click() 
}
setInterval(ClickConnect,60000)

image.png

To restart your training (In case the training does not finish and you get disconnected)

Checking the Mean Average Precision (mAP) of Your Model

Testing

5.jpg